import {Plugin} from 'vuepress'
import type MarkdownIt from "markdown-it"
import Shiki from '@shikijs/markdown-it'
import {ImportDemoBlock} from './importDemoBlock.ts'
import {resolve} from 'path'

interface VuepressPluginImportDemoBlockOption{
  codeTheme?: string;
  componentsDir: string
}


export function VuepressPluginImportDemoBlock(options:VuepressPluginImportDemoBlockOption ):Plugin{
  console.log('VuepressPluginImportDemoBlock');
  
  return {
    name: 'vuepress-plugin-import-demo-block',
    multiple: true,
    clientConfigFile: resolve(__dirname, '../client/index.ts'),
    extendsMarkdown: async (md:MarkdownIt) => {
      md.use(ImportDemoBlock({componentDir:options.componentsDir}))
      md.use(await Shiki({
        themes: {
          light: 'vitesse-light',
          dark: 'vitesse-dark',
        }
      }))
    },
  }
}